package completablefuture;


import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;

public class CompletableFutureTest {

    public static void main(String[] args) {

        CompletableFuture completableFuture = CompletableFuture.runAsync(new Task(100, (param) -> param + 10));


        System.out.println(completableFuture.getNow(null));
    }

    static class Task implements Runnable{

        private Function<Integer, Integer> function;

        private Integer param;

        public Task(Integer param, Function<Integer, Integer> function){
            this.param = param;
            this.function = function;
        }

        @Override
        public void run(){
            function.apply(param);
        }
    }
}
